//package com.kfh.ybracelet.net;
//
//import com.android.volley.toolbox.HurlStack;
//import com.squareup.okhttp.OkHttpClient;
//import com.squareup.okhttp.OkUrlFactory;
//
//import java.io.IOException;
//import java.net.HttpURLConnection;
//import java.net.URL;
//import java.util.Map;
//
//import javax.net.ssl.HttpsURLConnection;
//import javax.net.ssl.SSLSocketFactory;
//
///**
// * Created by Aaron on 16/4/26.
// */
//public class SelfSignSslOkHttpStack extends HurlStack {
//
//    private OkHttpClient okHttpClient;
//
//    private Map<String, SSLSocketFactory> socketFactoryMap;
//
//    /**
//     * Create a OkHttpStack with default OkHttpClient.
//     */
//    public SelfSignSslOkHttpStack(Map<String, SSLSocketFactory> socketFactoryMap) {
//        this(new OkHttpClient(), socketFactoryMap);
//    }
//
//
//    /**
//     * Create a OkHttpStack with a custom OkHttpClient
//     * @param okHttpClient Custom OkHttpClient, NonNull
//     */
//    public SelfSignSslOkHttpStack(OkHttpClient okHttpClient, Map<String, SSLSocketFactory> factoryMap) {
//        this.okHttpClient = okHttpClient;
//        this.socketFactoryMap = factoryMap;
//    }
//
//    @Override
//    protected HttpURLConnection createConnection(URL url) throws IOException {
//
//
////        AbstractHttpClient
////        new DefaultHttpClient()
//
//        if ("https".equals(url.getProtocol()) && socketFactoryMap.containsKey(url.getHost())) {
//            HttpsURLConnection connection = (HttpsURLConnection) new OkUrlFactory(okHttpClient).open(url);
//            connection.setSSLSocketFactory(socketFactoryMap.get(url.getHost()));
//            return connection;
//        } else {
//            return  new OkUrlFactory(okHttpClient).open(url);
//        }
//    }
//
//
//
//}
